<?php
function remove_menus () {
global $menu, $current_user;
if (!current_user_can('administrator')) {
		$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Settings'), __('Comments'), __('Plugins'));
		end ($menu);
		while (prev($menu)){
			$value = explode(' ',$menu[key($menu)][0]);
			if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
		}
}
}
add_action('admin_menu', 'remove_menus');
function remove_submenu() {
	global $submenu;
	//remove Theme editor
	if (!current_user_can('administrator')) {
	unset($submenu['tools.php'][5]);
	}
}
add_action('admin_menu', 'remove_submenu');
function user_roles(){
// THIS WORKS  http://sillybean.net/wordpress/users-and-roles/creating-roles/
$librarian = get_role('administrator'); /*choice of Administrator, Editor, Author, Contributor, Subscriber - http://codex.wordpress.org/Roles_and_Capabilities*/
$member = get_role('subscriber');
$caps = $librarian->capabilities;
$mems = $member->capabilities;

// Remove the stuff we don’t want in the new role.
unset($caps['activate_plugins']);
unset($caps['edit_plugins']);
unset($caps['update_plugins']);
unset($caps['delete_plugins']);
unset($caps['install_plugins']);
unset($caps['install_themes']);
unset($caps['delete_themes']);
unset($caps['edit_themes']);
unset($caps['edit_theme_options']);
unset($caps['switch_themes']);
unset($caps['update_core']);
unset($caps['edit_dashboard']);
unset($caps['manage_options']);
unset($caps['edit_files']);

// Add the new role.
add_role('Librarian', 'Librarian', $caps);
add_role('library-member', 'Library Member', $mems);
remove_role( 'subscriber' );
remove_role( 'contributor' );
remove_role( 'author' );
remove_role( 'editor' );
//remove_role( 'Librarian' );
}
add_action('init','user_roles');

?>